<?php
class Admin_Model_Category extends Zend_Db_Table_Abstract {
	protected $_name = "category_articles";
	protected $_primary = "id";

	/**
	 * get all category
	 *
	 * @return Ambigous
	 * @author Duy Thieu
	 */
	public function getCategory() {
		$query = $this->select ()->from ( $this->_name );
		$data = $this->fetchAll ( $query );
		return $data->toArray ();
	}

	/**
	 * get category
	 *
	 * @param int $id        	
	 * @return Ambigous
	 * @author Duy Thieu
	 */
	public function getCategoryOne($id) {
		$select = $this->select ()->from ( $this->_name )->where ( 'id = ?', $id );
		$data = $this->fetchRow ( $select );
		return $data;
	}

	/**
	 * get category
	 *
	 * @return Ambigous <multitype:, multitype:mixed >
	 * @author Duy Thieu
	 */
	public function getFetchPairs() {
		$query = "SELECT id, title
              FROM category_articles";
		return $this->_db->fetchPairs ( $query );
	}

	/**
	 * add
	 *
	 * @param array $data        	
	 * @return Ambigous
	 * @author Duy Thieu
	 */
	public function add($data) {
		return $this->insert ( $data );
	}

	public function edit($id, $data) {
		$where = "id=" . $id;
		$this->update ( $data, $where );
	}

}